/*
Code creates: 
-	Table A.5: Determinants of Groom Choices: Reduced Form Probit
*/

clear all
set more off

* load data
*-------------------------------------------------------------------------------
use "$data/initial_data/Groom_roster.dta"
destring, replace 

gen double  exper_id=carer_id*100+Groom_roster
codebook exper_id
duplicates drop exper_id, force

keep gs* exper_id

* generate choice variable
*-------------------------------------------------------------------------------
g chose_1 = gs_choice ==1 if gs_choice~=.

* generate differences in characteristics between the two options
*-------------------------------------------------------------------------------

* age of marriage
foreach i of numlist 14/22 {
	gen d_marage_`i'=(gs_age_opt1==`i')-(gs_age_opt2==`i')
	lab var d_marage_`i' "Bride's Age at Marriage=`i'"
	}

* school
foreach i of numlist   8 9 10 11 12 13 {
	gen d_marsch_`i'=(gs_schoolgrade_opt1==`i')-(gs_schoolgrade_opt2==`i')
	lab var d_marsch_`i' "Bride's Education =`i'"
	}	

* wealth	
g d_wealth_1 = (gs_wealth_opt1==1) - (gs_wealth_opt2==1)
lab var d_wealth_1 "Bride's Wealth = Poor"
g d_wealth_3 = (gs_wealth_opt1==3) - (gs_wealth_opt2==3)
lab var d_wealth_3 "Bride's Wealth = Wealthy"

g dd_wealth_11 = (gs_wealth_opt1==1 & gs_wealth_groom==1) - (gs_wealth_opt2==1 & gs_wealth_groom==1)
lab var dd_wealth_11 "Bride's Wealth = Poor, Groom's Wealth = Poor"
g dd_wealth_31 = (gs_wealth_opt1==3 & gs_wealth_groom==1) - (gs_wealth_opt2==3 & gs_wealth_groom==1)
lab var dd_wealth_31 "Bride's Wealth = Wealthy, Groom's Wealth = Poor"

g dd_wealth_12 = (gs_wealth_opt1==1 & gs_wealth_groom==2) - (gs_wealth_opt2==1 & gs_wealth_groom==2)
lab var dd_wealth_12 "Bride's Wealth = Poor, Groom's Wealth = Average"
g dd_wealth_32 = (gs_wealth_opt1==3 & gs_wealth_groom==2) - (gs_wealth_opt2==3 & gs_wealth_groom==2)
lab var dd_wealth_32 "Bride's Wealth = Wealthy, Groom's Wealth = Average"

g dd_wealth_13 = (gs_wealth_opt1==1 & gs_wealth_groom==3) - (gs_wealth_opt2==1 & gs_wealth_groom==3)
lab var dd_wealth_13 "Bride's Wealth = Poor, Groom's Wealth = Wealthy"
g dd_wealth_33 = (gs_wealth_opt1==3 & gs_wealth_groom==3) - (gs_wealth_opt2==3 & gs_wealth_groom==3)
lab var dd_wealth_33 "Bride's Wealth = Wealthy, Groom's Wealth = Wealthy"

* dowry
g d_dowry = (gs_dowry_opt1 - gs_dowry_opt2)
lab var d_dowry "Dowry"

* bride follows norms
g d_bad = (gs_goodgirl_opt1==0) - (gs_goodgirl_opt2==0)
lab var d_bad "Bride has Male Friends"

* education difference
g d_moreed = (gs_schoolgrade_opt1 > gs_schoolgrade_groom) - (gs_schoolgrade_opt2 > gs_schoolgrade_groom)
lab var d_moreed "Bride More Educated"

* interactions with groom's occupation
g gov_bad = gs_gov_groom*d_bad
lab var gov_bad "Gov = 1 \& Bride has Male Friends"
g gov_dowry = gs_gov_groom*d_dowry
lab var gov_dowry "Gov = 1 \& Dowry"
g gov_moreed = gs_gov_groom*d_moreed
lab var gov_moreed "Gov = 1 \& Bride More Educated"
foreach i in 14 15 16 17 18 19 20 21 22 {
	g g_gov_age`i' = gs_gov_groom*d_marage_`i'
	lab var g_gov_age`i' "Gov = 1 \& Bride's Age = `i'"
	}
foreach i in 8 9 10 11 12 13 {
	g g_gov_ed`i' = gs_gov_groom*d_marsch_`i'
	lab var g_gov_ed`i' "Gov = 1 \& Bride's Ed = `i'"
	}
g gdd_wealth_11 = dd_wealth_11*gs_gov
lab var gdd_wealth_11 "Gov = 1 \& Bride's Wealth = Poor, Groom's Wealth = Poor"
g gdd_wealth_31 = dd_wealth_31*gs_gov
lab var gdd_wealth_31 "Gov = 1 \& Bride's Wealth = Wealthy, Groom's Wealth = Poor"

g gdd_wealth_12 = dd_wealth_12*gs_gov
lab var gdd_wealth_12 "Gov = 1 \& Bride's Wealth = Poor, Groom's Wealth = Average"
g gdd_wealth_32 = dd_wealth_32*gs_gov
lab var gdd_wealth_32 "Gov = 1 \& Bride's Wealth = Wealthy, Groom's Wealth = Average"

g gdd_wealth_13 = dd_wealth_13*gs_gov
lab var gdd_wealth_13 "Gov = 1 \& Bride's Wealth = Poor, Groom's Wealth = Wealthy"
g gdd_wealth_33 = dd_wealth_33*gs_gov
lab var gdd_wealth_33 "Gov = 1 \& Bride's Wealth = Wealthy, Groom's Wealth = Wealthy"

* Run descriptive choice regressions
*-------------------------------------------------------------------------------

lab var chose_1 "Match Choice"

constraint define 2 [chose_1]_cons = 0
probit chose_1 d_marage_* d_marsch_* d_bad d_dowry d_wealth*, ///
		constraints(2) 
estimates store rf_groom_1
estadd local daughter_opts "yes"
estadd local match_opts "no"
estadd local interactions "no"
estadd local n_exps=e(N)

probit chose_1 d_marage_* d_marsch_* d_bad d_dowry dd_wealth* d_moreed, ///		
		constraints(2) 
estimates store rf_groom_2
estadd local daughter_opts "yes"
estadd local match_opts "yes"
estadd local interactions "no"
estadd local n_exps=e(N)

probit chose_1 d_marage_* d_marsch_* d_bad d_dowry dd_wealth* d_moreed ///
			g_gov_age* g_gov_ed* gov_bad gov_dowry gdd* gov_more, ///		
		constraints(2) 
estimates store rf_groom_3
estadd local daughter_opts "yes"
estadd local match_opts "yes"
estadd local interactions "yes"
estadd local n_exps=e(N)

esttab rf_groom_* , noobs ///
  wide b(4) se(4) label  replace noconstant nomtitles   star(* 0.10 ** 0.05 *** 0.01) nodepvars   ///
  scalars("daughter_opts  Daughter Options" "match_opts  Match Characteristics" "interactions Interactions" "n_exps Number of Choice Experiments")

esttab rf_groom_* using "$output/rf_groom.tex" , noobs ///
  wide b(4) se(4) label  replace noconstant nomtitles booktabs  star(* 0.10 ** 0.05 *** 0.01) nodepvars   ///
  scalars("daughter_opts  Daughter Options" "match_opts  Match Characteristics" "interactions Interactions" "n_exps Number of Choice Experiments")
